
#include <memory>
#include <functional>

#include "block.h"
#include "picture.h"

class CDecoderImpl
{
public:
    virtual int decode(std::shared_ptr<CDataBlock> spBlock) = 0;

};

//或许可以定义模板
class CVideoDecoderImpl : public CDecoderImpl
{
    using VFrameHandler = std::function<void(std::shared_ptr<CPicture> spPic)>;
protected:
  //设置解码数据回调，便于抽象层获取数据
    virtual int setFrameCallback(const VFrameHandler& ) = 0;
};

class CAudioFrameDecoderImpl : public CDecoderImpl
{
    using AudioFrameHandler = std::function<void(std::shared_ptr<CDataBlock> spAudioFrame)>;
protected:
  //设置解码数据回调，便于抽象层获取数据
    virtual int setFrameCallback(const AudioFrameHandler& ) = 0;
};

class CSpuFrameDecoderImpl : public CDecoderImpl
{
    using VFrameHandler = std::function<void(std::shared_ptr<CPicture> spPic)>;
protected:
  //设置解码数据回调，便于抽象层获取数据
    virtual int setFrameCallback(const VFrameHandler&) = 0;
};

class CDecoder
{
public:
    struct CDecodeOption
    {

    };
    void Init(CDecodeOption& option);
    void Decode(std::shared_ptr<CDataBlock> spBlock);
private:
    int LoadDecoder();
    int UnLoadDecoder();
    int ReloadDecoder();
protected:
   /* m_spImpl->setFrameCallback([&](std::shared_ptr<T> data){
        DecoderPlay(data);
    });*/
    std::shared_ptr<CDecoderImpl> m_spImpl;
 
    std::shared_ptr<CModule> m_spModule;
};